package com.example.bridge;

import com.example.bridge.Impi.AirConditioner;
import com.example.bridge.Impi.TV;
import com.example.bridge.extend.BasicControl;
import com.example.bridge.extend.PhoneControl;

/**
 * 桥接模式，通过抽象父类作为桥梁，去使用接口的实现类的方法。
 * 桥梁两边的代码都可以随意改动
 */
public class Test {
    public static void main(String[] args) {
        BasicControl basicControl1 = new BasicControl(new TV());

        basicControl1.turnOn();
        basicControl1.turnOf();

        BasicControl basicControl2 = new BasicControl(new AirConditioner());

        basicControl2.turnOn();
        basicControl2.turnOf();

        System.out.println();
        PhoneControl phoneControl1 = new PhoneControl(new TV());

        phoneControl1.turnOn();
        phoneControl1.turnOf();

        PhoneControl phoneControl2 = new PhoneControl(new AirConditioner());

        phoneControl2.turnOn();
        phoneControl2.turnOf();
    }
}
